/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__ora_new_report_body.c                           */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/15 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../../src/module/oracle/config.h"
#include "../../test_ora_comm.h"
#include <apmtest_comm.h>
#include <oracle/comm/ora_comm.h>
#include <oracle/comm/ora_util.h>
#include <frct_comm.h>

extern Frreport_body_data* __ora_new_report_body(Conntrack *p_st_conn
                                                , L7session_ora *p_st_sess);

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

/**
 * 正确测试
 */
static void __case1(void)
{
    Conntrack *p_st_conn = NULL;
    CU_ASSERT_EQUAL(test_ora_create_ct(&p_st_conn, TEST_ORA_SRC_IP, TEST_ORA_DST_IP, TEST_ORA_SRC_PORT, TEST_ORA_DST_PORT), FR_SUCC);

    L7_session *p_st_session = frct_get_session(p_st_conn);
    L7session_ora_private *p_st_session_private = (L7session_ora_private *) frct_get_session_private(p_st_session);
    L7session_ora *p_st_sess = p_st_session_private->p_st_sess;
    
    Frreport_body_data *p_st_body = NULL;
    p_st_body = __ora_new_report_body(p_st_conn, p_st_sess);
    CU_ASSERT_PTR_NOT_NULL(p_st_body);

    frreport_body_free(&p_st_body);

    test_ora_destroy_ct(&p_st_conn);
    CU_ASSERT_PTR_NULL(p_st_conn);
}

int add_suite__ora_new_report_body(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __ora_new_report_body()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
